# syntax=docker.io/docker/dockerfile:1.20
# This cannot be inlined below (e.g., COPY --from=maven:...) because Dependabot does not support that syntax yet
FROM maven:3.9.9 as maven

FROM ghcr.io/dependabot/dependabot-updater-core

RUN apt-get update && apt-get install -y --no-install-recommends \
    openjdk-21-jdk-headless \
    ca-certificates-java \
    && rm -rf /var/lib/apt/lists/*

COPY --from=maven /usr/share/maven /usr/share/maven

ENV MAVEN_HOME=/usr/share/maven

RUN ln -s ${MAVEN_HOME}/bin/mvn /usr/bin/mvn

USER dependabot

ENV PATH=$JAVA_HOME/bin:$PATH
ENV MAVEN_ARGS="-Dmaven.repo.local=$DEPENDABOT_HOME/.m2"

COPY --chown=dependabot:dependabot --parents maven common $DEPENDABOT_HOME/
COPY --chown=dependabot:dependabot updater $DEPENDABOT_HOME/dependabot-updater

# symlink so script/dependabot just works
RUN mkdir -p ~/.m2 && ln -s ~/maven/settings.xml ~/.m2/settings.xml
